package com.ldc.wandroid.viewmodel;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.ldc.common.mvvm.ViewModelBase;
import com.ldc.common.net.Api2Request;
import com.ldc.wandroid.model.ArticleModel;
import com.ldc.wandroid.server.ApiServer;

public class SystemInfoViewModel extends ViewModelBase {
    private final ApiServer apiServer = Api2Request.getInstance().createServer(ApiServer.class);
    private final MutableLiveData<ArticleModel> _systemInfo = new MutableLiveData<>();


    public LiveData<ArticleModel> getSystemInfo() {
        return _systemInfo;
    }


    public void getSystemInfo(int index, String cid) {
        apiRequest(apiServer.getSystemInfo(index, cid), (ok, result, throwable) -> {
            if (ok) {
                _systemInfo.setValue(result.getData());
            } else {
                _systemInfo.setValue(null);
            }
        });
    }

}
